package me.zhengjie.modules.quartz.task;

import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.summary.domain.Summary;
import me.zhengjie.modules.summary.repository.SummaryRepository;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class UploadDataToRabbit {


    @Resource
    private SummaryRepository summaryRepository;

    @Resource
    private RabbitTemplate rabbitmqTemplate;

    public void run(){

        log.info("启动成功");
        List<Summary> all = summaryRepository.findAll();
        rabbitmqTemplate.convertAndSend("firstQueue",new Gson().toJson(all));

    }

}
